﻿@model ManageReportVer1.Models.AccountModel

@{
    ViewBag.Title = "Register";
    Layout = "~/Views/Shared/_LayoutSecurityGuard.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div id="breadcrumb">
    @Html.ActionLink("Quản lý người dùng", "ViewUsers", "Account") >
    Tạo tài khoản
</div>
<h2>Tạo tài khoản mới</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Nhập thông tin người dùng</legend>
        <div class="row">
           @Html.LabelFor(model => model.UserName) 
            <div class="inputs">
            <span class="input_wrapper">@Html.TextBoxFor(model => model.UserName)</span>
            <span class="system negative" id="username-message">@Html.ValidationMessageFor(model => model.UserName)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.Password)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.Password)</span>
             <span class="system negative">@Html.ValidationMessageFor(model => model.Password)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.Email)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.Email)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Email)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.PasswordQuestion)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.PasswordQuestion)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.PasswordQuestion)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.PasswordAnswer)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.PasswordAnswer)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.PasswordAnswer)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.IsApproved)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.IsApproved)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.IsApproved)</span>
        </div>
        </div>
        

@*        <div class="editor-label">
            @Html.LabelFor(model => model.IsLockedOut)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.IsLockedOut)
            <span class="system negative">@Html.ValidationMessageFor(model => model.IsLockedOut)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CreateDate)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.CreateDate)
            <span class="system negative">@Html.ValidationMessageFor(model => model.CreateDate)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.LastLoginDate)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.LastLoginDate)
            <span class="system negative">@Html.ValidationMessageFor(model => model.LastLoginDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastPasswordChangedDate)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.LastPasswordChangedDate)
            <span class="system negative">@Html.ValidationMessageFor(model => model.LastPasswordChangedDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastLockoutDate)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.LastLockoutDate)
            <span class="system negative">@Html.ValidationMessageFor(model => model.LastLockoutDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FailedPasswordAttemptCount)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.FailedPasswordAttemptCount)
            <span class="system negative">@Html.ValidationMessageFor(model => model.FailedPasswordAttemptCount)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FailedPasswordAttemptWindowStart)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.FailedPasswordAttemptWindowStart)
            <span class="system negative">@Html.ValidationMessageFor(model => model.FailedPasswordAttemptWindowStart)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FailedPasswordAnswerAttemptCount)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.FailedPasswordAnswerAttemptCount)
            <span class="system negative">@Html.ValidationMessageFor(model => model.FailedPasswordAnswerAttemptCount)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FailedPasswordAnswerAttemptWindowsStart)
        </div>
        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.FailedPasswordAnswerAttemptWindowsStart)
            <span class="system negative">@Html.ValidationMessageFor(model => model.FailedPasswordAnswerAttemptWindowsStart)
        </div>*@

        <div class="row">
            @Html.LabelFor(model => model.Comment)
            <div class="inputs">
            @Html.TextAreaFor(model => model.Comment)
            <span class="system negative">@Html.ValidationMessageFor(model => model.Comment)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.DepartmentId)

            @*        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.DepartmentId)
            <span class="system negative">@Html.ValidationMessageFor(model => model.DepartmentId)
        </div>*@
            <div class="inputs">
                <p>
                    @Html.DropDownListFor(m => m.departmentId_Account, Model.DepartmentList_Account)
                </p>
            </div>
        </div>

        <div class="row">
            @Html.LabelFor(model => model.FirstName)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.FirstName)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.FirstName)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.LastName)
            <div class="inputs">
             <span class="input_wrapper">@Html.EditorFor(model => model.LastName)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.LastName)</span>
        </div>
        </div>
        



        <div class="row">
            @Html.LabelFor(model => model.Honorary)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.Honorary)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Honorary)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.Address)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.Address)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Address)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.Telephone)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.Telephone)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Telephone)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.NickName)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.NickName)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.NickName)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.DateOfBirth)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.DateOfBirth, new {pattern="(0[1-9]|1[0-9]|2[0-9]|3[01]).(0[1-9]|1[012]).[0-9]{4})" })</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.DateOfBirth)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.Gender)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.Gender)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Gender)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.MaritalStatus)
             <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.MaritalStatus)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.MaritalStatus)</span>
        </div>
        </div>
       

        <div class="row">
            @Html.LabelFor(model => model.Photo)
            <div class="inputs">
            <span class="input_wrapper"> @Html.EditorFor(model => model.Photo)</span>
            <span class="system negative">@Html.ValidationMessageFor(model => model.Photo)</span>
        </div>
        </div>
        

        <div class="row">
            @Html.LabelFor(model => model.RoleId)
        
@*        <div class="editor-field">
            <span class="input_wrapper"> @Html.EditorFor(model => model.RoleId)
            <span class="system negative">@Html.ValidationMessageFor(model => model.RoleId)
        </div>*@
            <div class="inputs">
        <p>
              @Html.DropDownListFor(m => m.roleId_Account, Model.RoleList_Account)
        </p>
            </div>
            </div>
        <div class="row">
            <p>
                <input type="submit" value="Create" />
            </p>
        </div>
    </fieldset>
}

<div class="backToView">
    @Html.ActionLink("Quay lại danh sách người dùng", "ViewUsers")
</div>
<script type="text/javascript">

    $(function () {
        $("#DateOfBirth").datepicker({
            changeMonth: true,
            changeYear: true
        });


        var msg = $("#username-message");
        var btn = $("input[type='submit']");

        $("#UserName").focus();

        $("#UserName").blur(function () {

            var username = $(this).val();

            if (username.length == 0) {
                alert("No username.");
                return;
            }

            $.ajax({
                url: '@Url.Action("CheckForUniqueUser", "Account")',
                dataType: 'json',
                type: 'GET',
                data: { userName: username },
                success: OnCheckForUniqueUserSuccess,
                error: OnCheckForUniqueUserError
            });
        });

        function OnCheckForUniqueUserSuccess(data) {
            if (data.Exists) {
                msg.text("This username already exists.  Please enter a new one.");
                btn.attr("disabled", "disabled");
            } else {
                msg.text("");
                btn.removeAttr("disabled");
            }
        }

        function OnCheckForUniqueUserError(xhr, status, error) {
            msg.text("There was an error checking uniqueness.");
        }
    });

</script>